﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using XDeal.BL.Implements;
using XDeal.DAL.Entities;
using XDeal.Common.Constants;

namespace XDEALWEB.Controllers
{
    public class ThongTinDealController : Controller
    {
        //
        // GET: /ThongTinDeal/id
        public ActionResult Index(int id)
        {
            bool isNull = false;
            ViewDataOneDeal(id, ref isNull);
            if (isNull == true)
                return RedirectToAction("Index", "Home");
            return View();
        }

        #region Private Functions
        /// <summary>
        /// View Data
        /// </summary>
        /// <param name="dealID"></param>
        /// <param name="isNull"></param>
        private void ViewDataOneDeal(int dealID, ref bool isNull)
        {
            DealBL obDealBL = new DealBL();
            Deal dealOB = obDealBL.GetValidDealByID(dealID);
            if (dealOB != null)
            {
                ViewData[ConstViewDataName.DealOB] = dealOB;
                isNull = false;
            }
            else
                isNull = true;
        }
        #endregion

    }
}
